package Teleasistencia;

import java.sql.*;

public class Query {

    protected Connection conn;
    protected PreparedStatement consulta;
    protected ResultSet datos;
    private Query query;

    public Query getConexion() {
        return query;
    }

    public Connection conectar(String servidor, String bd, String usuario, String contraseña) {
        try {
            Class.forName("org.gjt.mm.mysql.Driver");
            this.conn = DriverManager.getConnection("jdbc:mysql://" + servidor + "/" + bd, usuario, contraseña);
            //jdbc:mysql://
        } catch (ClassNotFoundException ex) {
            ex.printStackTrace();
        } catch (SQLException ex) {
            ex.printStackTrace();
        }
        return conn;
    }

    public void desconectar() throws SQLException {
        this.conn.close();
        this.consulta.close();
    }

    public void desconectar(ResultSet rs) throws SQLException {
        this.desconectar();
        rs.close();
    }
}
